package com.mashibing.serviceprice.service;

import com.mashibing.dto.ForecastPrice;
import com.mashibing.dto.PriceRule;
import com.mashibing.dto.ResponseResult;
import com.mashibing.serviceprice.mapper.PriceRuleMapper;
import com.mashibing.serviceprice.remote.ServiceMapRemote;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class ForecastPriceService {


    @Autowired
    private ServiceMapRemote serviceMapRemote;

    @Autowired
    private PriceRuleMapper priceRuleMapper;

    public ResponseResult forecastPrice(ForecastPrice forecastPrice) {

        // 地图服务 获取距离和时长
        ResponseResult driving = serviceMapRemote.driving(forecastPrice);

        // 获取数据库 计价规则
        Map<String,Object> map = new HashMap<>();
        map.put("cityCode","11000");
        List<PriceRule> priceRules = priceRuleMapper.selectByMap(map);
        log.info(priceRules + "");
        return ResponseResult.success(driving.getData());
    }
}
